const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    orderItemId: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "主键",
      field: "order_item_id"
    },
    orderId: {
      type: DataTypes.STRING(255),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "订单ID",
      field: "order_id"
    },
    shopItemId: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "店铺商品ID",
      field: "shop_item_id"
    },
    amount: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "成交金额（单价）;保留两位小数，单位元；使用积分时根据shop_item表的shop_price实时计算供参考",
      field: "amount"
    },
    point: {
      type: DataTypes.INTEGER(11),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "成交积分（单价）",
      field: "point"
    },
    basePrice: {
      type: DataTypes.DECIMAL,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "成交时成本单价;保留两位小数，单位元；使用积分时根据item表的base_price实时计算供参考",
      field: "base_price"
    },
    qty: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "数量",
      field: "qty"
    },
    remark: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "订单明细备注",
      field: "remark"
    },
    status: {
      type: DataTypes.INTEGER(1),
      allowNull: false,
      defaultValue: "1",
      primaryKey: false,
      autoIncrement: false,
      comment: "状态;正常，异常等状态应对部分退货等",
      field: "status"
    }
  };
  const options = {
    tableName: "order_item",
    comment: "",
    indexes: []
  };
  const OrderItemModel = sequelize.define("orderItemModel", attributes, options);
  return OrderItemModel;
};